package com.cgt.xiaotao.promotion.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cgt.xiaotao.promotion.domain.po.Coupon;
import com.cgt.xiaotao.promotion.domain.po.UserCoupon;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserCouponMapper extends BaseMapper<UserCoupon> {

    @Select("SELECT c.id, c.discount_type, c.`specific`, c.threshold_amount, c.discount_value, c.max_discount_amount, uc.id as creater\n"+
            "FROM\n"+
            "coupon c \n" +
            "INNER JOIN user_coupon uc ON c.id =uc.coupon_id\n"+
            "WHERE uc.user_id=#{userId} AND uc.`status`=1")
    List<Coupon> queryMyCoupon(Long userId);
}
